1109. 航班预订统计
为保证权益,题目请参考 1109. 航班预订统计(From LeetCode).
解决方案1
Python
python
# 1109. 航班预订统计
# https://leetcode-cn.com/problems/corporate-flight-bookings/
from typing import List
class Solution:
def corpFlightBookings(self, bookings: List[List[int]], n: int) -> List[int]:
cha = [0] * (n + 2)
for fir, las, ses in bookings:
cha[fir] += ses
cha[las + 1] -= ses
ans = [0] * n
ans[0] = cha[1]
for i in range(1, n):
ans[i] = ans[i - 1] + cha[i + 1]
return ans
if __name__ == "__main__":
solution = Solution()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23